<template>
    <div>
<el-dialog
  title="代偿确认"
  :visible.sync="dialogVisible"
  width="30%"
  :before-close="handleClose">
  <div class="main">
      <el-form>
           <el-form-item label="收款金额" label-width="120px" class="el-form-item">
               <span>{{row.amount}}</span>
              </el-form-item>
              <el-form-item label="借据号" label-width="120px" class="el-form-item">
                  <el-input v-model="form.borrowNo"></el-input>
              </el-form-item>
              <el-form-item label="应代偿金额" label-width="120px" class="el-form-item">
                  <el-input v-model="form.pipeiAmount" onkeyup="value=value.replace(/[^\d]/g,'')"></el-input>
              </el-form-item>
      </el-form>
  </div>
  <span slot="footer" class="dialog-footer">
    <el-button type="primary" @click="confirm">确 定</el-button>
  </span>
</el-dialog>
    </div>
</template>

<script>
import { dataPipei } from "@/api/antborrow/expenditure";
    export default {
        props:["dialogVisible","row"],
        data(){
            return {
                form:{
                    id:""
                }
            }
        },
        watch:{
            row(val){
                this.amount = val.amount
                this.form.id = val.id
            }
        },
        methods:{
            confirm(){
                dataPipei(this.form).then(res=>{
                    if(res.data.code == 0){
                       if(res.data.data == true){
                           this.$message({
                               type:"success",
                               message:"操作成功"
                           })
            
                        this.form.pipeiAmount = ""
                        this.form.borrowNo = ""
                        this.$emit("handleCurrentChange",1)
                       }else{
                           this.$message({
                               type:"error",
                               message:"操作失败"
                           })
                        this.form.borrowNo = ""
                        this.form.pipeiAmount = ""
                       }
                    }
                })

                
                this.$emit("closeWindow")
            },
            handleClose(){
                this.form.pipeiAmount = ""
                this.form.borrowNo = ""
                this.$emit("closeWindow")
            }
        }
    }
</script>

<style scoped>

</style>
